<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        //sort排序会改变原数组
        //sort()数组排序  
        //函数可以当作参数传入另一个函数
        var arr=[33,44,55,11]
        arr.sort(function(a,b){
            if(a>b){
                return 1;
            }
            else{
                return -1;
            }
        });
        console.log(arr)//[11,33,44,55]

        var arr1=[33,44,55,11]
        arr1.sort(function(a,b){
            return a-b;
        })
        console.log(arr1)//[11,33,44,55]
    </script>
</body>
</html>